//导入request请求工具
import request from '@/utils/request.js'
//提供调用注册接口的函数
export const userRegisterService=(registerData)=>{
    //借助UrlSearchParams完成传递
    const params = new URLSearchParams();
    // for (let key in registerDate) {
    //     params.append(key, registerDate[key]);
    // }
    params.append("username",registerData.userName);
    params.append("password",registerData.password);
    params.append("phoneNumber",registerData.phoneNumber);
    params.append("image",registerData.image)
    params.append("email",registerData.email)
    params.append("code1",registerData.code1)
    params.append("code2",registerData.code2)
    return request.post('/user/register',params);
}
//提供调用登录接口的函数
export const userLoginService=(loginDate)=>{
    const params = new URLSearchParams();
    for (let key in loginDate) {
        params.append(key, loginDate[key]);
    }
    return request.post('/user/login',params);
}
export const phoneService=(number,type)=>{
    const params = new URLSearchParams();
    params.append("number",number);
    params.append("type",type);

    return request.post('/user/msg',params);
}
//获取用户信息
export const userInfoService=()=>{
    return request.get('/user/userInfo');
}
export const emailService=(email,type)=>{
    const params = new URLSearchParams();
    params.append("email",email)
    params.append("type",type)
    return request.post('/user/email',params);
}

export const isLoginService=()=>{
    return request.post('/backend/login/isLogin');
}

export const BUserLogin=(info)=>{
    const params = new URLSearchParams();
    for (let key in info) {
        params.append(key, info[key]);
    }
    return request.post('/backend/login',params);
}

//根据用户名获取用户信息
export const userInfoByNameService=(name)=>{
    return request.get('/backend/user?name='+name);
}

export const userInfoByNumberService=(number)=>{
    return request.get('/backend/user/number?number='+number);
}

export const updateInfoByIdService=(id,status)=>{
    const params = new URLSearchParams();
    params.append('id',id);
    params.append('status',status);
    return request.post('/backend/user',params);
}